package uplb.ics.cs190.e2d.display;

import uplb.ics.cs190.e2d.graphics.Color;
import uplb.ics.cs190.e2d.graphics.Image;
import uplb.ics.cs190.e2d.graphics.MIDletImage;
import uplb.ics.cs190.e2d.lang.GSystem;

public class MIDletGraphics implements Graphics {

	protected javax.microedition.lcdui.Graphics graphics;
	
	public MIDletGraphics(javax.microedition.lcdui.Graphics graphics) {
		this.graphics = graphics;
	}
	
	public MIDletGraphics() {
		this.graphics = null;
	}
	
	public javax.microedition.lcdui.Graphics getGraphics() {
		return this.graphics;
	}
	
	public void setGraphics(javax.microedition.lcdui.Graphics graphics) {
		this.graphics = graphics;
	}
	
	public void setColor(Color color) {
		GSystem.verbose("Setting Color of MIDlet Graphics");
		this.graphics.setColor(
				color.getRed(), 
				color.getGreen(),
				color.getBlue());
		GSystem.verbose("Color --> " + this.graphics.getColor());
	}

	public void fillRect(int x, int y, int width, int height) {
		this.graphics.fillRect(x, y, width, height);
	}

	public void drawImage(Image image, int x, int y) {
		javax.microedition.lcdui.Image img = ((MIDletImage) image).getImage();
		this.graphics.drawImage(img, x, y, 0);
	}

}